package com.example.myapplication.activity;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;

import com.example.myapplication.R;
import com.example.myapplication.base.App;
import com.example.myapplication.base.BaseActivity;
import com.example.myapplication.http.BaseCallBack;
import com.example.myapplication.http.HttpHelp;
import com.example.myapplication.http.MemberData;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.gson.Gson;

public class MainActivity extends BaseActivity {

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        HttpHelp.get().ready("member", "getMemberData")
                .get(new BaseCallBack() {
                    @Override
                    public void onSuccess(String data) {
                        App.get().setMemberData(new Gson().fromJson(data, MemberData.class));
                    }

                    @Override
                    public void onFailure(String reason) {

                    }
                });

    }

    @Override
    public void initView() {

        setContentView(R.layout.activity_main);
        BottomNavigationView navView = findViewById(R.id.nav_view);
        AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
                R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications)
                .build();
        NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
        //NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
        NavigationUI.setupWithNavController(navView, navController);

    }

    @Override
    public void initEvent() {

    }
}
